package com.ruoyi.web.controller.student_club.admin_controller;

import java.util.List;

import com.ruoyi.student_club.vo.ExamineVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.student_club.domain.ClubExamine;
import com.ruoyi.student_club.service.IClubExamineService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审核管理Controller
 * 
 * @author 无尤
 * @date 2022-01-24
 */
@Controller
@RequestMapping("/examine/examine")
public class ClubExamineController extends BaseController
{
    private String prefix = "examine/examine";

    @Autowired
    private IClubExamineService clubExamineService;

    @RequiresPermissions("examine:examine:view")
    @GetMapping()
    public String examine()
    {
        return prefix + "/examine";
    }

    /**
     * 查询审核管理列表
     */
    @RequiresPermissions("examine:examine:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ClubExamine clubExamine)
    {
        startPage();
        List<ExamineVo> list = clubExamineService.selectClubExamineList(clubExamine);
        return getDataTable(list);
    }

    /**
     * 导出审核管理列表
     */
    @RequiresPermissions("examine:examine:export")
    @Log(title = "审核管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ClubExamine clubExamine)
    {
        List<ExamineVo> list = clubExamineService.selectClubExamineList(clubExamine);
        ExcelUtil<ExamineVo> util = new ExcelUtil<ExamineVo>(ExamineVo.class);
        return util.exportExcel(list, "审核管理数据");
    }

    /**
     * 修改审核管理
     */
    @RequiresPermissions("examine:examine:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ClubExamine clubExamine = clubExamineService.selectClubExamineById(id);
        mmap.put("clubExamine", clubExamine);
        return prefix + "/edit";
    }

    /**
     * 修改保存审核管理
     */
    @RequiresPermissions("examine:examine:edit")
    @Log(title = "审核管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ClubExamine clubExamine)
    {
        return toAjax(clubExamineService.updateClubExamine(clubExamine));
    }

    /**
     * 删除审核管理
     */
    @RequiresPermissions("examine:examine:remove")
    @Log(title = "审核管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(clubExamineService.deleteClubExamineByIds(ids));
    }
}
